package com.atguigu.oss.controller;

/*
 * @ClassName OssController
 * @author  忘忧君
 * @Description
 * @Version 1.0
 */

import com.atguigu.commonutils.R;
import com.atguigu.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api(description="oss图片管理")
@RestController
@RequestMapping("/eduoss/fileoss")
// @CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;

    @ApiOperation(value = "图片上传")
    @PostMapping
    public R uploadOssFile(MultipartFile file){
        // 获取上传文件 multipartfile
        String url = ossService.uploadFileAvatar(file);
        return R.ok().data("url", url);
    }
}
